home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
New Star Software Collection
/
NSS_Collection.iso
/
3-170 dbase 10 for windows
/
1.ima
/
SAMPLES.PAK
/
BINTREE.PRG
< prev
next >
Wrap
Text File
|
1993-07-26
|
1KB
|
77 lines
set talk off
use clients
x = new tree(contact,client_Id)
? "Scanning database and building binary tree.."
?
scan
?? '.'
d=x.addtree(contact,client_Id)
endscan
wait "Press any key to begin in-order traversal of binary tree..."
d=x.inOrder()
class tree
parameter newKey, newValue
member key, val, left, right, insert
* Constructor
key = newKey
val = newValue
left = .f.
right = .f.
function inOrder
* left
if .not. empty(left)
d=left.inOrder()
endif
* itself
? key, val
* right
if .not. empty(right)
d=right.inOrder()
endif
return (0)
function addtree
parameter newKey, newValue
d=insert(new tree(newKey, newValue))
return (0)
function insert
parameter o
if o.key < key
if (empty(left))
left = o
return(o)
else
return(left.insert(o))
endif
else
if (empty(right))
right = o
return(o)
else
return(right.insert(o))
endif
endif
endclass